package com.mzj.saas.mservice.bill.controller;

import com.mzj.saas.commons.ResultBean;
import com.mzj.saas.mservice.bill.service.BillAppService;
import com.mzj.saas.mservice.bill.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 公租房-费用app接口
 */
@Controller
@RequestMapping("/billApp")
public class BillAppController {
    @Autowired
    private BillAppService billAppService;

    /**
     * 租金账单列表
     *
     * @param accessToken
     * @param residenceCommunityId
     * @param buildingNum
     * @param unit
     * @param roomNumber
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @GetMapping("/rentBillList")
    @ResponseBody
    public ResultBean<BillApiData<RentBillListVO>> rentBillList(@RequestHeader String accessToken,
                                                                @RequestParam(required = false) String residenceCommunityId,
                                                                @RequestParam(required = false) Long buildingNum,
                                                                @RequestParam(required = false) Long unit,
                                                                @RequestParam(required = false) String roomNumber,
                                                                @RequestParam(defaultValue = "0") Integer pageNumber,
                                                                @RequestParam(defaultValue = "5") Integer pageSize,
                                                                @RequestParam(required = false) Long id) {
        return billAppService.rentBillList(accessToken, residenceCommunityId, buildingNum, unit, roomNumber, pageNumber, pageSize, id);
    }

    /**
     * 租金账单详情
     *
     * @param id
     * @return
     */
    @GetMapping("/rentBillDetail")
    @ResponseBody
    public ResultBean<RentBillDetailVO> rentBillDetail(@RequestParam(value = "id") Long id) {
        return billAppService.rentBillDetail(id);
    }

    /**
     * 其他费用列表
     *
     * @param accessToken
     * @param residenceCommunityId
     * @param buildingNum
     * @param unit
     * @param roomNumber
     * @param chargeType
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @GetMapping("/expenseBillList")
    @ResponseBody
    public ResultBean<BillApiData<ExpenseBillListVO>> expenseBillList(@RequestHeader String accessToken,
                                                                      @RequestParam(required = false) String residenceCommunityId,
                                                                      @RequestParam(required = false) Long buildingNum,
                                                                      @RequestParam(required = false) Long unit,
                                                                      @RequestParam(required = false) String roomNumber,
                                                                      @RequestParam(value = "chargeType", required = false) Integer chargeType,
                                                                      @RequestParam(defaultValue = "0") Integer pageNumber,
                                                                      @RequestParam(defaultValue = "5") Integer pageSize,
                                                                      @RequestParam(required = false) Long id) {
        return billAppService.expenseBillList(accessToken, residenceCommunityId, buildingNum, unit, roomNumber, chargeType, pageNumber, pageSize, id);
    }

    /**
     * 支付记录列表
     *
     * @param accessToken
     * @param businessType
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @GetMapping("/paymentOrderList")
    @ResponseBody
    public ResultBean<PaymentOrderApiData<PaymentOrderListVO>> paymentOrderList(@RequestHeader String accessToken,
                                                                                @RequestParam(value = "businessType", required = false) Integer businessType,
                                                                                @RequestParam(defaultValue = "0") Integer pageNumber,
                                                                                @RequestParam(defaultValue = "5") Integer pageSize) {
        return billAppService.paymentOrderList(accessToken, businessType, pageNumber, pageSize);
    }

    /**
     * 租金/押金app支付
     *
     * @param accessToken
     * @return
     */
    @PostMapping("/payment")
    @ResponseBody
    public ResultBean<Map<String, Object>> payment(@RequestHeader String accessToken, @RequestBody RentBillPaymentVo vo) {
        return billAppService.payment(accessToken, vo);
    }

    /**
     * 其它费用账单APP支付
     *
     * @param accessToken
     * @param vo
     * @return
     * @author shun
     * @date 2021年7月12日
     */
    @PostMapping("/other/payment")
    @ResponseBody
    public ResultBean<Map<String, Object>> OtherPayment(@RequestHeader String accessToken, @RequestBody RentBillPaymentVo vo) {
        return billAppService.otherPayment(accessToken, vo);
    }

    /**
     * 租金账单列表-待办事项
     *
     * @param accessToken
     * @param backlogItemId
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @GetMapping("/backlogRentBillList")
    @ResponseBody
    public ResultBean<BillApiData<RentBillListVO>> backlogRentBillList(@RequestHeader String accessToken,
                                                                       @RequestParam Long backlogItemId,
                                                                       @RequestParam(defaultValue = "0") Integer pageNumber,
                                                                       @RequestParam(defaultValue = "5") Integer pageSize) {
        return billAppService.backlogRentBillList(accessToken, backlogItemId, pageNumber, pageSize);
    }


}
